#!/bin/bash

ulimit -c unlimited -n 8192

# 优化SERVER获取方式
if [ -f ".namelock" ]; then
    SERVER=`cat .namelock`
else
    SERVER="ckwy"
fi


if [ "${SERVER}" == "" ]
then
        echo "path error!"
        exit 1
fi

PID=`ps aux | grep logic | grep -v grep | grep ${SERVER} | awk '{print $2}'`

if [ "${PID}" != "" ]
then
        echo "Process logic ${SERVER} exists, exit"
        exit 1
fi

echo "Start pokemon logic..."
nohup ./logic ${SERVER} > nohup.logic.out &

sleep 4
if ps aux | grep logic | grep --color=always ${SERVER} 
then
	echo "Game server start ok! ${SERVER} "
fi
